package com.example.common.enums;

/**
 * 业务类型
 */
public enum StatusTypeEnum {
    //0正常 1异常
    NORMAL(0, "正常"),
    EXCEPTION(1, "异常");

    private int key;
    private String value;


    StatusTypeEnum(int key, String value) {
        this.key = key;
        this.value = value;
    }

    public int getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public void setKey(int key) {
        this.key = key;
    }

    //根据key获取value
    public static String getValue(int key) {
        for (StatusTypeEnum operatorTypeEnum : values()){
            if (operatorTypeEnum.getKey() == key){
                return operatorTypeEnum.getValue();
            }
        }
        return "";
    }

    //根据value获取key
    public static int getKey(String value) {
        for (StatusTypeEnum operatorTypeEnum : values()){
            if (operatorTypeEnum.getValue().equals(value)){
                return operatorTypeEnum.getKey();
            }
        }
        return 0;
    }


}


